import {createBrowserRouter} from 'react-router-dom'
import App from '../App'
import { lazy } from 'react'

type RouterType={
    path:string,
    element:JSX.Element,
    children?:{path:string,
        element:JSX.Element}[]
}[]

const router:RouterType=[
   {
    path:'/',
    element:<App/>,
    children:[
        {
            path:'/home',
            async lazy(){
                const {default:Home}=await import('../pages/home/Index')
                return{
                    element:<Home/>
                }
            }
        },
        {
            path:'/todo',
            async lazy(){
                const {default:Tode}=await import('../pages/todo/Index')
                return{
                    element:<Tode/>
                }
            }
        },
        {
            path:'/message',
            async lazy(){
                const {default:Message}=await import('../pages/message/Index')
                return{
                    element:<Message/>
                }
            }
        },
        {
            path:'/my',
            async lazy(){
                const {default:My}=await import('../pages/my/Index')
                return{
                    element:<My/>
                }
            }
        },
        {
            path:'/list',
            async lazy(){
                const {default:List}=await import('../pages/list/Index')
                return{
                    element:<List/>,
                  
                }
            },
            children:[
                {
                    path:'/list/data',
                    async lazy(){
                        const {default:Data}=await import('../pages/list/data/Index')
                        return{
                            element:<Data/>
                        }
                    }
                },
                {
                    path:'/list/data1',
                    async lazy(){
                        const {default:Data1}=await import('../pages/list/data1/Index')
                        return{
                            element:<Data1/>
                        }
                    }
                },
                {
                    path:'/list/data2',
                    async lazy(){
                        const {default:Data2}=await import('../pages/list/data2/Index')
                        return{
                            element:<Data2/>
                        }
                    }
                },
            ]
        },
    ]
   }
]
const routes=createBrowserRouter(router)

export default routes;